import Vue from "vue";
import "./cube-ui";
import App from "./App.vue";
import router from "./router";
import Axios from "axios";
import request from "./common/request.js";
import qs from "qs";
import "amfe-flexible";
import "animate.css";
import "./assets/fonts/iconfont.js";
import "./assets/fonts/iconfont.css";
import {iSession,iLocal} from "./common/cache";

request("member/easyFind",{
    activity_id: 1
},true);
Vue.prototype.$http = Axios;
Vue.prototype.$request = request;
window.Qs = qs;
Vue.prototype.$qs = qs;
Vue.prototype.$sysinfo = window.sysinfo;
Vue.prototype.$map = window.AMap;
if(!window.sysinfo.develop){
    Vue.prototype.$wx = window.wx;  //微信对象
    window.wx.ready(()=>{
            window.wx.hideMenuItems({
                menuList: ["menuItem:copyUrl","menuItem:originPage","menuItem:openWithQQBrowser","menuItem:openWithSafari","menuItem:share:email","menuItem:delete"]
            });
        });
}
//设置储存 sessionStorage
Vue.prototype.$iSession = iSession;
window.iSession = iSession;
//设置储存 localStorage
Vue.prototype.$iLocal = iLocal;
window.iLocal = iLocal;
//页面高度
document.documentElement.style.height = document.documentElement.clientHeight+"px";
Vue.config.productionTip = false;


router.beforeEach((to,from,next)=>{
  //页面名称
  switch(to.name){
    case "index":
      document.title = window.sysinfo.webname;
      break;
    case "activity":
      Axios.post(window.sysinfo.url,window.Qs.stringify({
          pages:"activity",
          doing:"name",
          activity_id:to.params.activity_id
      }))
          .then((res)=>{
            if(res.data.status == "success"){
              document.title = res.data.data;
            }else{
              document.title = "活动";
            }
          })
          .catch();
      break;
    default:
      document.title = to.meta.title;
      break;
  }
  next();
});

new Vue({
  router,
  render: h => h(App)
}).$mount("#app");

router.afterEach(()=>{
    setTimeout(()=>{
        window.scroll(0,0);
    },100);
});
